<?xml version="1.0" encoding="UTF-8"?>
<dxl:DXLMessage xmlns:dxl="http://greenplum.com/dxl/2010/12/">
  <dxl:Comment><![CDATA[
    Objective: The aggregate should have a materialize on top if it is the
    inner child of a nested loop join. This will help with the performance.

    EXPLAIN
    WITH un1 AS (
        SELECT
            unnest('{rerum,velit,p,q,r,s,t,um,v,q,w,e,r,t,y,u,i}'::text[]) val,
            unnest(coalesce( CASE
                WHEN array_length('{rerum,velit}'::text[],1) =
                    array_length(array[1.0]::float[],1)
                THEN array[1.0]::float[]
                END,
                array_fill(1.0::double precision,
                    array[coalesce(array_length('{rerum,velit,p,q,r,s,t,u,v,w}'::text[], 1), 0)]
                    )
            )) wt
    ),
    mw AS (
        SELECT avg(wt) AS w FROM un1
    ),
    un2 AS (
        SELECT unnest('{odio,beatae, a, b, c ,d, e, f,g}'::text[]) val
    )
    SELECT coalesce(
        sum(CASE when u1.val is not distinct FROM u2.val then u1.wt else 0.0 end * 2) /
            nullif(
                sum(CASE
                    WHEN u1.val is not distinct FROM u2.val
                    THEN 2 ELSE 1
                    END
                    * coalesce(u1.wt,m.w)
                ),
            0),
        0)
    FROM
        un1 u1
        FULL OUTER JOIN
        un2 u2
            on u1.val = u2.val
        CROSS JOIN
        mw m ;
                                                  QUERY PLAN
    -------------------------------------------------------------------------------------------------------
     Sequence  (cost=0.00..1324033.15 rows=1 width=8)
       ->  Shared Scan (share slice:id 0:0)  (cost=0.00..0.00 rows=1 width=1)
             ->  ProjectSet  (cost=0.00..0.00 rows=1 width=16)
                   ->  Result  (cost=0.00..0.00 rows=1 width=1)
       ->  Aggregate  (cost=0.00..1324033.15 rows=1 width=16)
             ->  Nested Loop  (cost=0.00..1324033.15 rows=3 width=32)
                   Join Filter: true
                   ->  Merge Full Join  (cost=0.00..431.00 rows=3 width=24)
                         Merge Cond: (share0_ref3.val = (unnest('{odio,beatae,a,b,c,d,e,f,g}'::anyarray)))
                         ->  Sort  (cost=0.00..431.00 rows=1 width=16)
                               Sort Key: share0_ref3.val
                               ->  Shared Scan (share slice:id 0:0)  (cost=0.00..431.00 rows=1 width=16)
                         ->  Sort  (cost=0.00..0.00 rows=1 width=8)
                               Sort Key: (unnest('{odio,beatae,a,b,c,d,e,f,g}'::anyarray))
                               ->  ProjectSet  (cost=0.00..0.00 rows=1 width=8)
                                     ->  Result  (cost=0.00..0.00 rows=1 width=1)
                   ->  Materialize  (cost=0.00..431.00 rows=1 width=8)
                         ->  Aggregate  (cost=0.00..431.00 rows=1 width=8)
                               ->  Shared Scan (share slice:id 0:0)  (cost=0.00..431.00 rows=1 width=8)
     Optimizer: Pivotal Optimizer (GPORCA)
    (20 rows)
  ]]>
  </dxl:Comment>
  <dxl:Thread Id="0">
    <dxl:OptimizerConfig>
      <dxl:EnumeratorConfig Id="0" PlanSamples="0" CostThreshold="0"/>
      <dxl:StatisticsConfig DampingFactorFilter="0.750000" DampingFactorJoin="0.000000" DampingFactorGroupBy="0.750000" MaxStatsBuckets="100"/>
      <dxl:CTEConfig CTEInliningCutoff="0"/>
      <dxl:WindowOids RowNumber="3100" Rank="3101"/>
      <dxl:CostModelConfig CostModelType="1" SegmentsForCosting="3">
        <dxl:CostParams>
          <dxl:CostParam Name="NLJFactor" Value="1024.000000" LowerBound="1023.500000" UpperBound="1024.500000"/>
        </dxl:CostParams>
      </dxl:CostModelConfig>
      <dxl:Hint JoinArityForAssociativityCommutativity="18" ArrayExpansionThreshold="100" JoinOrderDynamicProgThreshold="10" BroadcastThreshold="100000" EnforceConstraintsOnDML="false" PushGroupByBelowSetopThreshold="10" XformBindThreshold="0"/>
      <dxl:TraceFlags Value="102001,102002,102003,102043,102074,102120,102144,103001,103003,103014,103022,103026,103027,103029,103033,103038,103040,104002,104003,104004,104005,105000,106000"/>
    </dxl:OptimizerConfig>
    <dxl:Metadata SystemIds="0.GPDB">
      <dxl:Type Mdid="0.16.1.0" Name="bool" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="1" PassByValue="true">
        <dxl:DistrOpfamily Mdid="0.2222.1.0"/>
        <dxl:LegacyDistrOpfamily Mdid="0.7124.1.0"/>
        <dxl:EqualityOp Mdid="0.91.1.0"/>
        <dxl:InequalityOp Mdid="0.85.1.0"/>
        <dxl:LessThanOp Mdid="0.58.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.1694.1.0"/>
        <dxl:GreaterThanOp Mdid="0.59.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.1695.1.0"/>
        <dxl:ComparisonOp Mdid="0.1693.1.0"/>
        <dxl:ArrayType Mdid="0.1000.1.0"/>
        <dxl:MinAgg Mdid="0.0.0.0"/>
        <dxl:MaxAgg Mdid="0.0.0.0"/>
        <dxl:AvgAgg Mdid="0.0.0.0"/>
        <dxl:SumAgg Mdid="0.0.0.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:Type Mdid="0.23.1.0" Name="int4" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="4" PassByValue="true">
        <dxl:DistrOpfamily Mdid="0.1977.1.0"/>
        <dxl:LegacyDistrOpfamily Mdid="0.7100.1.0"/>
        <dxl:EqualityOp Mdid="0.96.1.0"/>
        <dxl:InequalityOp Mdid="0.518.1.0"/>
        <dxl:LessThanOp Mdid="0.97.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.523.1.0"/>
        <dxl:GreaterThanOp Mdid="0.521.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.525.1.0"/>
        <dxl:ComparisonOp Mdid="0.351.1.0"/>
        <dxl:ArrayType Mdid="0.1007.1.0"/>
        <dxl:MinAgg Mdid="0.2132.1.0"/>
        <dxl:MaxAgg Mdid="0.2116.1.0"/>
        <dxl:AvgAgg Mdid="0.2101.1.0"/>
        <dxl:SumAgg Mdid="0.2108.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:GPDBScalarOp Mdid="0.664.1.0" Name="&lt;" ComparisonType="LT" ReturnsNullOnNullInput="true" IsNDVPreserving="false">
        <dxl:LeftType Mdid="0.25.1.0"/>
        <dxl:RightType Mdid="0.25.1.0"/>
        <dxl:ResultType Mdid="0.16.1.0"/>
        <dxl:OpFunc Mdid="0.740.1.0"/>
        <dxl:Commutator Mdid="0.666.1.0"/>
        <dxl:InverseOp Mdid="0.667.1.0"/>
        <dxl:Opfamilies>
          <dxl:Opfamily Mdid="0.1994.1.0"/>
          <dxl:Opfamily Mdid="0.4017.1.0"/>
          <dxl:Opfamily Mdid="0.4056.1.0"/>
          <dxl:Opfamily Mdid="0.10018.1.0"/>
        </dxl:Opfamilies>
      </dxl:GPDBScalarOp>
      <dxl:Type Mdid="0.25.1.0" Name="text" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="true" IsFixedLength="false" Length="-1" PassByValue="false">
        <dxl:DistrOpfamily Mdid="0.1995.1.0"/>
        <dxl:LegacyDistrOpfamily Mdid="0.7105.1.0"/>
        <dxl:EqualityOp Mdid="0.98.1.0"/>
        <dxl:InequalityOp Mdid="0.531.1.0"/>
        <dxl:LessThanOp Mdid="0.664.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.665.1.0"/>
        <dxl:GreaterThanOp Mdid="0.666.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.667.1.0"/>
        <dxl:ComparisonOp Mdid="0.360.1.0"/>
        <dxl:ArrayType Mdid="0.1009.1.0"/>
        <dxl:MinAgg Mdid="0.2145.1.0"/>
        <dxl:MaxAgg Mdid="0.2129.1.0"/>
        <dxl:AvgAgg Mdid="0.0.0.0"/>
        <dxl:SumAgg Mdid="0.0.0.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:GPDBFunc Mdid="0.2331.1.0" Name="unnest" ReturnsSet="true" Stability="Immutable" DataAccess="NoSQL" IsStrict="true" IsNDVPreserving="false" IsAllowedForPS="false">
        <dxl:ResultType Mdid="0.2283.1.0"/>
      </dxl:GPDBFunc>
      <dxl:GPDBScalarOp Mdid="0.670.1.0" Name="=" ComparisonType="Eq" ReturnsNullOnNullInput="true" IsNDVPreserving="false">
        <dxl:LeftType Mdid="0.701.1.0"/>
        <dxl:RightType Mdid="0.701.1.0"/>
        <dxl:ResultType Mdid="0.16.1.0"/>
        <dxl:OpFunc Mdid="0.293.1.0"/>
        <dxl:Commutator Mdid="0.670.1.0"/>
        <dxl:InverseOp Mdid="0.671.1.0"/>
        <dxl:HashOpfamily Mdid="0.1971.1.0"/>
        <dxl:LegacyHashOpfamily Mdid="0.7102.1.0"/>
        <dxl:Opfamilies>
          <dxl:Opfamily Mdid="0.1970.1.0"/>
          <dxl:Opfamily Mdid="0.1971.1.0"/>
          <dxl:Opfamily Mdid="0.4070.1.0"/>
          <dxl:Opfamily Mdid="0.7102.1.0"/>
          <dxl:Opfamily Mdid="0.10007.1.0"/>
        </dxl:Opfamilies>
      </dxl:GPDBScalarOp>
      <dxl:MDCast Mdid="3.2277.1.0;25.1.0" Name="text" BinaryCoercible="false" SourceTypeId="0.2277.1.0" DestinationTypeId="0.25.1.0" CastFuncId="0.25.1.0" CoercePathType="0"/>
      <dxl:MDCast Mdid="3.25.1.0;25.1.0" Name="text" BinaryCoercible="true" SourceTypeId="0.25.1.0" DestinationTypeId="0.25.1.0" CastFuncId="0.25.1.0" CoercePathType="0"/>
      <dxl:GPDBAgg Mdid="0.2105.1.0" Name="avg" IsSplittable="true" HashAggCapable="true">
        <dxl:ResultType Mdid="0.701.1.0"/>
        <dxl:IntermediateResultType Mdid="0.1022.1.0"/>
      </dxl:GPDBAgg>
      <dxl:GPDBFunc Mdid="0.316.1.0" Name="float8" ReturnsSet="false" Stability="Immutable" DataAccess="NoSQL" IsStrict="true" IsNDVPreserving="false" IsAllowedForPS="false">
        <dxl:ResultType Mdid="0.701.1.0"/>
      </dxl:GPDBFunc>
      <dxl:Type Mdid="0.701.1.0" Name="float8" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="true" Length="8" PassByValue="true">
        <dxl:DistrOpfamily Mdid="0.1971.1.0"/>
        <dxl:LegacyDistrOpfamily Mdid="0.7102.1.0"/>
        <dxl:EqualityOp Mdid="0.670.1.0"/>
        <dxl:InequalityOp Mdid="0.671.1.0"/>
        <dxl:LessThanOp Mdid="0.672.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.673.1.0"/>
        <dxl:GreaterThanOp Mdid="0.674.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.675.1.0"/>
        <dxl:ComparisonOp Mdid="0.355.1.0"/>
        <dxl:ArrayType Mdid="0.1022.1.0"/>
        <dxl:MinAgg Mdid="0.2136.1.0"/>
        <dxl:MaxAgg Mdid="0.2120.1.0"/>
        <dxl:AvgAgg Mdid="0.2105.1.0"/>
        <dxl:SumAgg Mdid="0.2111.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:GPDBAgg Mdid="0.2111.1.0" Name="sum" IsSplittable="true" HashAggCapable="true">
        <dxl:ResultType Mdid="0.701.1.0"/>
        <dxl:IntermediateResultType Mdid="0.701.1.0"/>
      </dxl:GPDBAgg>
      <dxl:GPDBScalarOp Mdid="0.593.1.0" Name="/" ComparisonType="Other" ReturnsNullOnNullInput="true" IsNDVPreserving="false">
        <dxl:LeftType Mdid="0.701.1.0"/>
        <dxl:RightType Mdid="0.701.1.0"/>
        <dxl:ResultType Mdid="0.701.1.0"/>
        <dxl:OpFunc Mdid="0.217.1.0"/>
      </dxl:GPDBScalarOp>
      <dxl:GPDBScalarOp Mdid="0.594.1.0" Name="*" ComparisonType="Other" ReturnsNullOnNullInput="true" IsNDVPreserving="false">
        <dxl:LeftType Mdid="0.701.1.0"/>
        <dxl:RightType Mdid="0.701.1.0"/>
        <dxl:ResultType Mdid="0.701.1.0"/>
        <dxl:OpFunc Mdid="0.216.1.0"/>
        <dxl:Commutator Mdid="0.594.1.0"/>
      </dxl:GPDBScalarOp>
      <dxl:MDCast Mdid="3.1022.1.0;701.1.0" Name="float8" BinaryCoercible="false" SourceTypeId="0.1022.1.0" DestinationTypeId="0.701.1.0" CastFuncId="0.701.1.0" CoercePathType="0"/>
      <dxl:GPDBScalarOp Mdid="0.98.1.0" Name="=" ComparisonType="Eq" ReturnsNullOnNullInput="true" IsNDVPreserving="false">
        <dxl:LeftType Mdid="0.25.1.0"/>
        <dxl:RightType Mdid="0.25.1.0"/>
        <dxl:ResultType Mdid="0.16.1.0"/>
        <dxl:OpFunc Mdid="0.67.1.0"/>
        <dxl:Commutator Mdid="0.98.1.0"/>
        <dxl:InverseOp Mdid="0.531.1.0"/>
        <dxl:HashOpfamily Mdid="0.1995.1.0"/>
        <dxl:LegacyHashOpfamily Mdid="0.7105.1.0"/>
        <dxl:Opfamilies>
          <dxl:Opfamily Mdid="0.1994.1.0"/>
          <dxl:Opfamily Mdid="0.1995.1.0"/>
          <dxl:Opfamily Mdid="0.2095.1.0"/>
          <dxl:Opfamily Mdid="0.2229.1.0"/>
          <dxl:Opfamily Mdid="0.4017.1.0"/>
          <dxl:Opfamily Mdid="0.4056.1.0"/>
          <dxl:Opfamily Mdid="0.7105.1.0"/>
          <dxl:Opfamily Mdid="0.10018.1.0"/>
          <dxl:Opfamily Mdid="0.10022.1.0"/>
        </dxl:Opfamilies>
      </dxl:GPDBScalarOp>
      <dxl:Type Mdid="0.2277.1.0" Name="anyarray" IsRedistributable="false" IsHashable="false" IsMergeJoinable="false" IsComposite="false" IsTextRelated="false" IsFixedLength="false" Length="-1" PassByValue="false">
        <dxl:EqualityOp Mdid="0.0.0.0"/>
        <dxl:InequalityOp Mdid="0.0.0.0"/>
        <dxl:LessThanOp Mdid="0.0.0.0"/>
        <dxl:LessThanEqualsOp Mdid="0.0.0.0"/>
        <dxl:GreaterThanOp Mdid="0.0.0.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.0.0.0"/>
        <dxl:ComparisonOp Mdid="0.0.0.0"/>
        <dxl:ArrayType Mdid="0.0.0.0"/>
        <dxl:MinAgg Mdid="0.2051.1.0"/>
        <dxl:MaxAgg Mdid="0.2050.1.0"/>
        <dxl:AvgAgg Mdid="0.0.0.0"/>
        <dxl:SumAgg Mdid="0.0.0.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
      <dxl:MDCast Mdid="3.23.1.0;701.1.0" Name="float8" BinaryCoercible="false" SourceTypeId="0.23.1.0" DestinationTypeId="0.701.1.0" CastFuncId="0.316.1.0" CoercePathType="1"/>
      <dxl:Type Mdid="0.1022.1.0" Name="_float8" IsRedistributable="true" IsHashable="true" IsMergeJoinable="true" IsComposite="false" IsTextRelated="false" IsFixedLength="false" Length="-1" PassByValue="false">
        <dxl:DistrOpfamily Mdid="0.627.1.0"/>
        <dxl:EqualityOp Mdid="0.1070.1.0"/>
        <dxl:InequalityOp Mdid="0.1071.1.0"/>
        <dxl:LessThanOp Mdid="0.1072.1.0"/>
        <dxl:LessThanEqualsOp Mdid="0.1074.1.0"/>
        <dxl:GreaterThanOp Mdid="0.1073.1.0"/>
        <dxl:GreaterThanEqualsOp Mdid="0.1075.1.0"/>
        <dxl:ComparisonOp Mdid="0.382.1.0"/>
        <dxl:ArrayType Mdid="0.0.0.0"/>
        <dxl:MinAgg Mdid="0.0.0.0"/>
        <dxl:MaxAgg Mdid="0.0.0.0"/>
        <dxl:AvgAgg Mdid="0.0.0.0"/>
        <dxl:SumAgg Mdid="0.6219.1.0"/>
        <dxl:CountAgg Mdid="0.2147.1.0"/>
      </dxl:Type>
    </dxl:Metadata>
    <dxl:Query>
      <dxl:OutputColumns>
        <dxl:Ident ColId="15" ColName="coalesce" TypeMdid="0.701.1.0"/>
      </dxl:OutputColumns>
      <dxl:CTEList>
        <dxl:LogicalCTEProducer CTEId="1" Columns="2,3">
          <dxl:LogicalProject>
            <dxl:ProjList>
              <dxl:ProjElem ColId="2" Alias="val">
                <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.25.1.0">
                  <dxl:ConstValue TypeMdid="0.2277.1.0" Value="AAAAqAEAAAAAAAAAGQAAABEAAAABAAAAAAAACXJlcnVtAAAAAAAACXZlbGl0&#10;AAAAAAAABXAAAAAAAAAFcQAAAAAAAAVyAAAAAAAABXMAAAAAAAAFdAAAAAAA&#10;AAZ1bQAAAAAABXYAAAAAAAAFcQAAAAAAAAV3AAAAAAAABWUAAAAAAAAFcgAA&#10;AAAAAAV0AAAAAAAABXkAAAAAAAAFdQAAAAAAAAVpAAAA"/>
                </dxl:FuncExpr>
              </dxl:ProjElem>
              <dxl:ProjElem ColId="3" Alias="wt">
                <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.701.1.0">
                  <dxl:ConstValue TypeMdid="0.1022.1.0" Value="AAAAaAEAAAAAAAAAvQIAAAoAAAABAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAA&#10;APA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAA&#10;AAAAAPA/AAAAAAAA8D8="/>
                </dxl:FuncExpr>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:LogicalConstTable>
              <dxl:Columns>
                <dxl:Column ColId="1" Attno="1" ColName="" TypeMdid="0.16.1.0"/>
              </dxl:Columns>
              <dxl:ConstTuple>
                <dxl:Datum TypeMdid="0.16.1.0" Value="true"/>
              </dxl:ConstTuple>
            </dxl:LogicalConstTable>
          </dxl:LogicalProject>
        </dxl:LogicalCTEProducer>
        <dxl:LogicalCTEProducer CTEId="2" Columns="6">
          <dxl:LogicalGroupBy>
            <dxl:GroupingColumns/>
            <dxl:ProjList>
              <dxl:ProjElem ColId="6" Alias="w">
                <dxl:AggFunc AggMdid="0.2105.1.0" AggDistinct="false" AggStage="Normal" AggKind="n" AggArgTypes="701">
                  <dxl:ValuesList ParamType="aggargs">
                    <dxl:Ident ColId="5" ColName="wt" TypeMdid="0.701.1.0"/>
                  </dxl:ValuesList>
                  <dxl:ValuesList ParamType="aggdirectargs"/>
                  <dxl:ValuesList ParamType="aggorder"/>
                  <dxl:ValuesList ParamType="aggdistinct"/>
                </dxl:AggFunc>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:LogicalCTEConsumer CTEId="1" Columns="4,5"/>
          </dxl:LogicalGroupBy>
        </dxl:LogicalCTEProducer>
        <dxl:LogicalCTEProducer CTEId="3" Columns="8">
          <dxl:LogicalProject>
            <dxl:ProjList>
              <dxl:ProjElem ColId="8" Alias="val">
                <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.25.1.0">
                  <dxl:ConstValue TypeMdid="0.2277.1.0" Value="AAAAZAEAAAAAAAAAGQAAAAkAAAABAAAAAAAACG9kaW8AAAAKYmVhdGFlAAAA&#10;AAAFYQAAAAAAAAViAAAAAAAABWMAAAAAAAAFZAAAAAAAAAVlAAAAAAAABWYA&#10;AAAAAAAFZwAAAA=="/>
                </dxl:FuncExpr>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:LogicalConstTable>
              <dxl:Columns>
                <dxl:Column ColId="7" Attno="1" ColName="" TypeMdid="0.16.1.0"/>
              </dxl:Columns>
              <dxl:ConstTuple>
                <dxl:Datum TypeMdid="0.16.1.0" Value="true"/>
              </dxl:ConstTuple>
            </dxl:LogicalConstTable>
          </dxl:LogicalProject>
        </dxl:LogicalCTEProducer>
      </dxl:CTEList>
      <dxl:LogicalCTEAnchor CTEId="1">
        <dxl:LogicalCTEAnchor CTEId="2">
          <dxl:LogicalCTEAnchor CTEId="3">
            <dxl:LogicalProject>
              <dxl:ProjList>
                <dxl:ProjElem ColId="15" Alias="coalesce">
                  <dxl:Coalesce TypeMdid="0.701.1.0">
                    <dxl:OpExpr OperatorName="/" OperatorMdid="0.593.1.0" OperatorType="0.701.1.0">
                      <dxl:Ident ColId="13" ColName="sum" TypeMdid="0.701.1.0"/>
                      <dxl:NullIf OperatorMdid="0.670.1.0" TypeMdid="0.701.1.0">
                        <dxl:Ident ColId="14" ColName="sum" TypeMdid="0.701.1.0"/>
                        <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
                      </dxl:NullIf>
                    </dxl:OpExpr>
                    <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
                  </dxl:Coalesce>
                </dxl:ProjElem>
              </dxl:ProjList>
              <dxl:LogicalGroupBy>
                <dxl:GroupingColumns/>
                <dxl:ProjList>
                  <dxl:ProjElem ColId="13" Alias="sum">
                    <dxl:AggFunc AggMdid="0.2111.1.0" AggDistinct="false" AggStage="Normal" AggKind="n" AggArgTypes="701">
                      <dxl:ValuesList ParamType="aggargs">
                        <dxl:OpExpr OperatorName="*" OperatorMdid="0.594.1.0" OperatorType="0.701.1.0">
                          <dxl:If TypeMdid="0.701.1.0">
                            <dxl:Not>
                              <dxl:IsDistinctFrom OperatorMdid="0.98.1.0">
                                <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                                <dxl:Ident ColId="11" ColName="val" TypeMdid="0.25.1.0"/>
                              </dxl:IsDistinctFrom>
                            </dxl:Not>
                            <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                            <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
                          </dxl:If>
                          <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAEA=" DoubleValue="2.000000"/>
                        </dxl:OpExpr>
                      </dxl:ValuesList>
                      <dxl:ValuesList ParamType="aggdirectargs"/>
                      <dxl:ValuesList ParamType="aggorder"/>
                      <dxl:ValuesList ParamType="aggdistinct"/>
                    </dxl:AggFunc>
                  </dxl:ProjElem>
                  <dxl:ProjElem ColId="14" Alias="sum">
                    <dxl:AggFunc AggMdid="0.2111.1.0" AggDistinct="false" AggStage="Normal" AggKind="n" AggArgTypes="701">
                      <dxl:ValuesList ParamType="aggargs">
                        <dxl:OpExpr OperatorName="*" OperatorMdid="0.594.1.0" OperatorType="0.701.1.0">
                          <dxl:FuncExpr FuncId="0.316.1.0" FuncRetSet="false" TypeMdid="0.701.1.0">
                            <dxl:If TypeMdid="0.23.1.0">
                              <dxl:Not>
                                <dxl:IsDistinctFrom OperatorMdid="0.98.1.0">
                                  <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                                  <dxl:Ident ColId="11" ColName="val" TypeMdid="0.25.1.0"/>
                                </dxl:IsDistinctFrom>
                              </dxl:Not>
                              <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/>
                              <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/>
                            </dxl:If>
                          </dxl:FuncExpr>
                          <dxl:Coalesce TypeMdid="0.701.1.0">
                            <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                            <dxl:Ident ColId="12" ColName="w" TypeMdid="0.701.1.0"/>
                          </dxl:Coalesce>
                        </dxl:OpExpr>
                      </dxl:ValuesList>
                      <dxl:ValuesList ParamType="aggdirectargs"/>
                      <dxl:ValuesList ParamType="aggorder"/>
                      <dxl:ValuesList ParamType="aggdistinct"/>
                    </dxl:AggFunc>
                  </dxl:ProjElem>
                </dxl:ProjList>
                <dxl:LogicalJoin JoinType="Inner">
                  <dxl:LogicalJoin JoinType="Full">
                    <dxl:LogicalCTEConsumer CTEId="1" Columns="9,10"/>
                    <dxl:LogicalCTEConsumer CTEId="3" Columns="11"/>
                    <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.98.1.0">
                      <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                      <dxl:Ident ColId="11" ColName="val" TypeMdid="0.25.1.0"/>
                    </dxl:Comparison>
                  </dxl:LogicalJoin>
                  <dxl:LogicalCTEConsumer CTEId="2" Columns="12"/>
                  <dxl:ConstValue TypeMdid="0.16.1.0" Value="true"/>
                </dxl:LogicalJoin>
              </dxl:LogicalGroupBy>
            </dxl:LogicalProject>
          </dxl:LogicalCTEAnchor>
        </dxl:LogicalCTEAnchor>
      </dxl:LogicalCTEAnchor>
    </dxl:Query>
    <dxl:Plan Id="0" SpaceSize="432">
      <dxl:Sequence>
        <dxl:Properties>
          <dxl:Cost StartupCost="0" TotalCost="1324033.254833" Rows="1.000000" Width="8"/>
        </dxl:Properties>
        <dxl:ProjList>
          <dxl:ProjElem ColId="20" Alias="coalesce">
            <dxl:Ident ColId="20" ColName="coalesce" TypeMdid="0.701.1.0"/>
          </dxl:ProjElem>
        </dxl:ProjList>
        <dxl:CTEProducer CTEId="0" Columns="1,2">
          <dxl:Properties>
            <dxl:Cost StartupCost="0" TotalCost="0.000118" Rows="1.000000" Width="1"/>
          </dxl:Properties>
          <dxl:ProjList>
            <dxl:ProjElem ColId="1" Alias="val">
              <dxl:Ident ColId="1" ColName="val" TypeMdid="0.25.1.0"/>
            </dxl:ProjElem>
            <dxl:ProjElem ColId="2" Alias="wt">
              <dxl:Ident ColId="2" ColName="wt" TypeMdid="0.701.1.0"/>
            </dxl:ProjElem>
          </dxl:ProjList>
          <dxl:Result>
            <dxl:Properties>
              <dxl:Cost StartupCost="0" TotalCost="0.000117" Rows="1.000000" Width="16"/>
            </dxl:Properties>
            <dxl:ProjList>
              <dxl:ProjElem ColId="1" Alias="val">
                <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.25.1.0">
                  <dxl:ConstValue TypeMdid="0.2277.1.0" Value="AAAAqAEAAAAAAAAAGQAAABEAAAABAAAAAAAACXJlcnVtAAAAAAAACXZlbGl0&#xA;AAAAAAAABXAAAAAAAAAFcQAAAAAAAAVyAAAAAAAABXMAAAAAAAAFdAAAAAAA&#xA;AAZ1bQAAAAAABXYAAAAAAAAFcQAAAAAAAAV3AAAAAAAABWUAAAAAAAAFcgAA&#xA;AAAAAAV0AAAAAAAABXkAAAAAAAAFdQAAAAAAAAVpAAAA"/>
                </dxl:FuncExpr>
              </dxl:ProjElem>
              <dxl:ProjElem ColId="2" Alias="wt">
                <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.701.1.0">
                  <dxl:ConstValue TypeMdid="0.1022.1.0" Value="AAAAaAEAAAAAAAAAvQIAAAoAAAABAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAA&#xA;APA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAA&#xA;AAAAAPA/AAAAAAAA8D8="/>
                </dxl:FuncExpr>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:Filter/>
            <dxl:OneTimeFilter/>
            <dxl:Result>
              <dxl:Properties>
                <dxl:Cost StartupCost="0" TotalCost="0.000001" Rows="1.000000" Width="1"/>
              </dxl:Properties>
              <dxl:ProjList>
                <dxl:ProjElem ColId="0" Alias="">
                  <dxl:ConstValue TypeMdid="0.16.1.0" Value="true"/>
                </dxl:ProjElem>
              </dxl:ProjList>
              <dxl:Filter/>
              <dxl:OneTimeFilter/>
            </dxl:Result>
          </dxl:Result>
        </dxl:CTEProducer>
        <dxl:Result>
          <dxl:Properties>
            <dxl:Cost StartupCost="0" TotalCost="1324033.254707" Rows="1.000000" Width="8"/>
          </dxl:Properties>
          <dxl:ProjList>
            <dxl:ProjElem ColId="20" Alias="coalesce">
              <dxl:Coalesce TypeMdid="0.701.1.0">
                <dxl:OpExpr OperatorName="/" OperatorMdid="0.593.1.0" OperatorType="0.701.1.0">
                  <dxl:Ident ColId="18" ColName="sum" TypeMdid="0.701.1.0"/>
                  <dxl:NullIf OperatorMdid="0.670.1.0" TypeMdid="0.701.1.0">
                    <dxl:Ident ColId="19" ColName="sum" TypeMdid="0.701.1.0"/>
                    <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
                  </dxl:NullIf>
                </dxl:OpExpr>
                <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
              </dxl:Coalesce>
            </dxl:ProjElem>
          </dxl:ProjList>
          <dxl:Filter/>
          <dxl:OneTimeFilter/>
          <dxl:Aggregate AggregationStrategy="Plain" StreamSafe="false">
            <dxl:Properties>
              <dxl:Cost StartupCost="0" TotalCost="1324033.254699" Rows="1.000000" Width="16"/>
            </dxl:Properties>
            <dxl:GroupingColumns/>
            <dxl:ProjList>
              <dxl:ProjElem ColId="18" Alias="sum">
                <dxl:AggFunc AggMdid="0.2111.1.0" AggDistinct="false" AggStage="Normal" AggKind="n">
                  <dxl:ValuesList ParamType="aggargs">
                    <dxl:OpExpr OperatorName="*" OperatorMdid="0.594.1.0" OperatorType="0.701.1.0">
                      <dxl:If TypeMdid="0.701.1.0">
                        <dxl:Not>
                          <dxl:IsDistinctFrom OperatorMdid="0.98.1.0">
                            <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                            <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                          </dxl:IsDistinctFrom>
                        </dxl:Not>
                        <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                        <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAAA=" DoubleValue="0.000000"/>
                      </dxl:If>
                      <dxl:ConstValue TypeMdid="0.701.1.0" Value="AAAAAAAAAEA=" DoubleValue="2.000000"/>
                    </dxl:OpExpr>
                  </dxl:ValuesList>
                  <dxl:ValuesList ParamType="aggdirectargs"/>
                  <dxl:ValuesList ParamType="aggorder"/>
                  <dxl:ValuesList ParamType="aggdistinct"/>
                </dxl:AggFunc>
              </dxl:ProjElem>
              <dxl:ProjElem ColId="19" Alias="sum">
                <dxl:AggFunc AggMdid="0.2111.1.0" AggDistinct="false" AggStage="Normal" AggKind="n">
                  <dxl:ValuesList ParamType="aggargs">
                    <dxl:OpExpr OperatorName="*" OperatorMdid="0.594.1.0" OperatorType="0.701.1.0">
                      <dxl:Cast TypeMdid="0.701.1.0" FuncId="0.316.1.0">
                        <dxl:If TypeMdid="0.23.1.0">
                          <dxl:Not>
                            <dxl:IsDistinctFrom OperatorMdid="0.98.1.0">
                              <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                              <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                            </dxl:IsDistinctFrom>
                          </dxl:Not>
                          <dxl:ConstValue TypeMdid="0.23.1.0" Value="2"/>
                          <dxl:ConstValue TypeMdid="0.23.1.0" Value="1"/>
                        </dxl:If>
                      </dxl:Cast>
                      <dxl:Coalesce TypeMdid="0.701.1.0">
                        <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                        <dxl:Ident ColId="14" ColName="w" TypeMdid="0.701.1.0"/>
                      </dxl:Coalesce>
                    </dxl:OpExpr>
                  </dxl:ValuesList>
                  <dxl:ValuesList ParamType="aggdirectargs"/>
                  <dxl:ValuesList ParamType="aggorder"/>
                  <dxl:ValuesList ParamType="aggdistinct"/>
                </dxl:AggFunc>
              </dxl:ProjElem>
            </dxl:ProjList>
            <dxl:Filter/>
            <dxl:NestedLoopJoin JoinType="Inner" IndexNestedLoopJoin="false" OuterRefAsParam="false">
              <dxl:Properties>
                <dxl:Cost StartupCost="0" TotalCost="1324033.254613" Rows="3.000000" Width="32"/>
              </dxl:Properties>
              <dxl:ProjList>
                <dxl:ProjElem ColId="9" Alias="val">
                  <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                </dxl:ProjElem>
                <dxl:ProjElem ColId="10" Alias="wt">
                  <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                </dxl:ProjElem>
                <dxl:ProjElem ColId="12" Alias="val">
                  <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                </dxl:ProjElem>
                <dxl:ProjElem ColId="14" Alias="w">
                  <dxl:Ident ColId="14" ColName="w" TypeMdid="0.701.1.0"/>
                </dxl:ProjElem>
              </dxl:ProjList>
              <dxl:Filter/>
              <dxl:JoinFilter>
                <dxl:ConstValue TypeMdid="0.16.1.0" Value="true"/>
              </dxl:JoinFilter>
              <dxl:MergeJoin JoinType="Full" UniqueOuter="false">
                <dxl:Properties>
                  <dxl:Cost StartupCost="0" TotalCost="431.000759" Rows="3.000000" Width="24"/>
                </dxl:Properties>
                <dxl:ProjList>
                  <dxl:ProjElem ColId="9" Alias="val">
                    <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                  </dxl:ProjElem>
                  <dxl:ProjElem ColId="10" Alias="wt">
                    <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                  </dxl:ProjElem>
                  <dxl:ProjElem ColId="12" Alias="val">
                    <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                  </dxl:ProjElem>
                </dxl:ProjList>
                <dxl:Filter/>
                <dxl:JoinFilter/>
                <dxl:MergeCondList>
                  <dxl:Comparison ComparisonOperator="=" OperatorMdid="0.98.1.0">
                    <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                    <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                  </dxl:Comparison>
                </dxl:MergeCondList>
                <dxl:Sort SortDiscardDuplicates="false">
                  <dxl:Properties>
                    <dxl:Cost StartupCost="0" TotalCost="431.000039" Rows="1.000000" Width="16"/>
                  </dxl:Properties>
                  <dxl:ProjList>
                    <dxl:ProjElem ColId="9" Alias="val">
                      <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                    </dxl:ProjElem>
                    <dxl:ProjElem ColId="10" Alias="wt">
                      <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                    </dxl:ProjElem>
                  </dxl:ProjList>
                  <dxl:Filter/>
                  <dxl:SortingColumnList>
                    <dxl:SortingColumn ColId="9" SortOperatorMdid="0.664.1.0" SortOperatorName="&lt;" SortNullsFirst="false"/>
                  </dxl:SortingColumnList>
                  <dxl:LimitCount/>
                  <dxl:LimitOffset/>
                  <dxl:CTEConsumer CTEId="0" Columns="9,10">
                    <dxl:Properties>
                      <dxl:Cost StartupCost="0" TotalCost="431.000039" Rows="1.000000" Width="16"/>
                    </dxl:Properties>
                    <dxl:ProjList>
                      <dxl:ProjElem ColId="9" Alias="val">
                        <dxl:Ident ColId="9" ColName="val" TypeMdid="0.25.1.0"/>
                      </dxl:ProjElem>
                      <dxl:ProjElem ColId="10" Alias="wt">
                        <dxl:Ident ColId="10" ColName="wt" TypeMdid="0.701.1.0"/>
                      </dxl:ProjElem>
                    </dxl:ProjList>
                  </dxl:CTEConsumer>
                </dxl:Sort>
                <dxl:Sort SortDiscardDuplicates="false">
                  <dxl:Properties>
                    <dxl:Cost StartupCost="0" TotalCost="0.000109" Rows="1.000000" Width="8"/>
                  </dxl:Properties>
                  <dxl:ProjList>
                    <dxl:ProjElem ColId="12" Alias="val">
                      <dxl:Ident ColId="12" ColName="val" TypeMdid="0.25.1.0"/>
                    </dxl:ProjElem>
                  </dxl:ProjList>
                  <dxl:Filter/>
                  <dxl:SortingColumnList>
                    <dxl:SortingColumn ColId="12" SortOperatorMdid="0.664.1.0" SortOperatorName="&lt;" SortNullsFirst="false"/>
                  </dxl:SortingColumnList>
                  <dxl:LimitCount/>
                  <dxl:LimitOffset/>
                  <dxl:Result>
                    <dxl:Properties>
                      <dxl:Cost StartupCost="0" TotalCost="0.000109" Rows="1.000000" Width="8"/>
                    </dxl:Properties>
                    <dxl:ProjList>
                      <dxl:ProjElem ColId="12" Alias="val">
                        <dxl:FuncExpr FuncId="0.2331.1.0" FuncRetSet="true" TypeMdid="0.25.1.0">
                          <dxl:ConstValue TypeMdid="0.2277.1.0" Value="AAAAZAEAAAAAAAAAGQAAAAkAAAABAAAAAAAACG9kaW8AAAAKYmVhdGFlAAAA&#xA;AAAFYQAAAAAAAAViAAAAAAAABWMAAAAAAAAFZAAAAAAAAAVlAAAAAAAABWYA&#xA;AAAAAAAFZwAAAA=="/>
                        </dxl:FuncExpr>
                      </dxl:ProjElem>
                    </dxl:ProjList>
                    <dxl:Filter/>
                    <dxl:OneTimeFilter/>
                    <dxl:Result>
                      <dxl:Properties>
                        <dxl:Cost StartupCost="0" TotalCost="0.000001" Rows="1.000000" Width="1"/>
                      </dxl:Properties>
                      <dxl:ProjList>
                        <dxl:ProjElem ColId="13" Alias="">
                          <dxl:ConstValue TypeMdid="0.16.1.0" Value="true"/>
                        </dxl:ProjElem>
                      </dxl:ProjList>
                      <dxl:Filter/>
                      <dxl:OneTimeFilter/>
                    </dxl:Result>
                  </dxl:Result>
                </dxl:Sort>
              </dxl:MergeJoin>
              <dxl:Materialize Eager="false">
                <dxl:Properties>
                  <dxl:Cost StartupCost="0" TotalCost="431.000028" Rows="1.000000" Width="8"/>
                </dxl:Properties>
                <dxl:ProjList>
                  <dxl:ProjElem ColId="14" Alias="w">
                    <dxl:Ident ColId="14" ColName="w" TypeMdid="0.701.1.0"/>
                  </dxl:ProjElem>
                </dxl:ProjList>
                <dxl:Filter/>
                <dxl:Aggregate AggregationStrategy="Plain" StreamSafe="false">
                  <dxl:Properties>
                    <dxl:Cost StartupCost="0" TotalCost="431.000020" Rows="1.000000" Width="8"/>
                  </dxl:Properties>
                  <dxl:GroupingColumns/>
                  <dxl:ProjList>
                    <dxl:ProjElem ColId="14" Alias="w">
                      <dxl:AggFunc AggMdid="0.2105.1.0" AggDistinct="false" AggStage="Normal" AggKind="n">
                        <dxl:ValuesList ParamType="aggargs">
                          <dxl:Ident ColId="16" ColName="wt" TypeMdid="0.701.1.0"/>
                        </dxl:ValuesList>
                        <dxl:ValuesList ParamType="aggdirectargs"/>
                        <dxl:ValuesList ParamType="aggorder"/>
                        <dxl:ValuesList ParamType="aggdistinct"/>
                      </dxl:AggFunc>
                    </dxl:ProjElem>
                  </dxl:ProjList>
                  <dxl:Filter/>
                  <dxl:CTEConsumer CTEId="0" Columns="15,16">
                    <dxl:Properties>
                      <dxl:Cost StartupCost="0" TotalCost="431.000019" Rows="1.000000" Width="8"/>
                    </dxl:Properties>
                    <dxl:ProjList>
                      <dxl:ProjElem ColId="15" Alias="val">
                        <dxl:Ident ColId="15" ColName="val" TypeMdid="0.25.1.0"/>
                      </dxl:ProjElem>
                      <dxl:ProjElem ColId="16" Alias="wt">
                        <dxl:Ident ColId="16" ColName="wt" TypeMdid="0.701.1.0"/>
                      </dxl:ProjElem>
                    </dxl:ProjList>
                  </dxl:CTEConsumer>
                </dxl:Aggregate>
              </dxl:Materialize>
            </dxl:NestedLoopJoin>
          </dxl:Aggregate>
        </dxl:Result>
      </dxl:Sequence>
    </dxl:Plan>
  </dxl:Thread>
</dxl:DXLMessage>
